package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.dataauth.annotation.member.MemberAuth;
import com.ssy.lingxi.member.merchant.api.model.vo.inner.response.MemberManageQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.MemberNameVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.ProvinceCodeVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.UpperRelationIdAndAreaCodeVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.UpperRelationIdVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.CountryAreaCodeNameVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.MemberAppraisalPageQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.MemberCreditComplaintPageQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.MemberRecordInspectPageQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.response.MemberRecordRectifyVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.request.*;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.*;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.MemberAbilityMaintenanceMemberQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.MemberValidateVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.ValidateIdPageVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.ValidateIdVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.response.MemberClassifyCategoryItemVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.response.MemberClassifyQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.response.MemberValidateDetailLevelVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberAbilityMaintenanceService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 会员能力-会员管理-会员信息相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-31
 */
@RestController
@RequestMapping("/member/ability/maintenance")
public class MemberAbilityMaintenanceController {
    @Resource
    private IMemberAbilityMaintenanceService memberAbilityMaintenanceService;

    /**
     * 列表查询页面中各个下拉选择框的内容
     * @param headers Http头部信息
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems", method = RequestMethod.GET)
    public Wrapper<MemberMaintenanceSearchConditionVO> getPageCondition(@RequestHeader HttpHeaders headers) {
        return memberAbilityMaintenanceService.getPageCondition(headers);
    }

    /**
     * 分页、模糊查询会员
     * @param headers Http头部信息
     * @param queryVO 接口参数
     * @return 操作结果
     */
    @MemberAuth
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberMaintenancePageQueryVO>> pageMembers(@RequestHeader HttpHeaders headers, @Valid MemberAbilityMaintenanceMemberQueryVO queryVO) {
        return memberAbilityMaintenanceService.pageMembers(headers, queryVO);
    }

    /**
     * 分页、模糊查询平台会员信息列表 - 会员引入
     * @param headers HttpHeaders信息
     * @param queryVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/platform/page", method = RequestMethod.GET)
    public Wrapper<PageData<PlatformPageQueryMemberVO>> pagePlatformMembers(@RequestHeader HttpHeaders headers, @Valid PlatformMemberQueryVO queryVO) {
        return memberAbilityMaintenanceService.pagePlatformMembers(headers, queryVO);
    }

    /**
     * 会员处理页面 - 会员详情
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<MemberMaintenanceDetailVO> getMemberBasicDetail(@RequestHeader HttpHeaders headers, @Valid ValidateIdVO idVO) {
        return memberAbilityMaintenanceService.getSubMemberDetail(headers, idVO);
    }

    /**
     * 会员处理 - 会员冻结、解冻
     * @param headers Http头部信息
     * @param statusVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/freeze", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberRelationStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberFreezeStatusVO statusVO) {
        return memberAbilityMaintenanceService.updateMemberRelationFreezeStatus(headers, statusVO);
    }

    /**
     * 会员处理 - 会员淘汰（解除关系）
     * @param headers HttpHeaders信息
     * @param vo 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/eliminate", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberEliminatedStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberEliminateOrBlacklistVO vo) {
        return memberAbilityMaintenanceService.updateMemberEliminatedStatus(headers, vo);
    }

    /**
     * 会员处理 - 会员黑名单
     * @param headers HttpHeaders信息
     * @param vo 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/blacklist", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberBlacklistStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberEliminateOrBlacklistVO vo) {
        return memberAbilityMaintenanceService.updateMemberBlacklistStatus(headers, vo);
    }

    /**
     * 会员详情 - 会员基本信息
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/basic", method = RequestMethod.GET)
    public Wrapper<MemberMaintenanceDetailBasicVO> getMemberDetailBasic(@RequestHeader HttpHeaders headers, @Valid ValidateIdVO idVO) {
        return memberAbilityMaintenanceService.getMemberDetailBasic(headers, idVO);
    }

    /**
     * 会员详情 - 查询渠道信息（修改页面）
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/basic/channel", method = RequestMethod.GET)
    public Wrapper<MemberMaintenanceChannelVO> getMemberDetailChannel(@RequestHeader HttpHeaders headers, @Valid ValidateIdVO idVO) {
        return memberAbilityMaintenanceService.getMemberDetailChannel(headers, idVO);
    }

    /**
     * 会员详情 - 修改渠道信息 - 查询省列表
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 返回信息
     */
    @RequestMapping(value = "/detail/basic/channel/province", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> getProvinceList(@RequestHeader HttpHeaders headers, @Valid UpperRelationIdVO idVO) {
        return memberAbilityMaintenanceService.getProvinceList(headers, idVO);
    }

    /**
     * 会员详情 - 修改渠道信息 - 查询市列表
     * @param headers Http头部信息
     * @param codeVO 接口参数
     * @return 返回信息
     */
    @RequestMapping(value = "/detail/basic/channel/city", method = RequestMethod.GET)
   public Wrapper<List<CountryAreaCodeNameVO>> getCityList(@RequestHeader HttpHeaders headers, @Valid UpperRelationIdAndAreaCodeVO codeVO) {
       return memberAbilityMaintenanceService.getCityList(headers, codeVO);
   }

    /**
     * 会员详情 - 修改渠道信息
     * @param headers Http头部信息
     * @param updateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/basic/channel/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberDetailChannel(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberMaintenanceChannelUpdateVO updateVO) {
        return memberAbilityMaintenanceService.updateMemberDetailChannel(headers, updateVO);
    }

    /**
     * 会员详情 - 会员档案信息
     * @param headers HttpHeader信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/record", method = RequestMethod.GET)
    public Wrapper<MemberMaintenanceRecordVO> getMemberRecords(@RequestHeader HttpHeaders headers, @Valid ValidateIdVO idVO) {
        return memberAbilityMaintenanceService.getMemberRecords(headers, idVO);
    }

    /**
     * 会员详情 - 会员档案 - 查询入库分类信息（修改页面）
     * @param headers HttpHeader信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/record/classify", method = RequestMethod.GET)
    public Wrapper<MemberClassifyQueryVO> getMemberClassification(@RequestHeader HttpHeaders headers, @Valid ValidateIdVO idVO) {
        return memberAbilityMaintenanceService.getMemberClassification(headers, idVO);
    }

    /**
     * 会员详情 - 会员档案 - 修改入库分类 - 省列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/record/classify/province", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> getClassifyProvinces(@RequestHeader HttpHeaders headers) {
        return memberAbilityMaintenanceService.getClassifyProvinces(headers);
    }

    /**
     * 会员详情 - 会员档案 - 修改入库分类 - 查询市列表
     * @param headers Http头部信息
     * @param codeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/record/classify/city", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> getClassifyCities(@RequestHeader HttpHeaders headers, @Valid ProvinceCodeVO codeVO) {
        return memberAbilityMaintenanceService.getClassifyCities(headers, codeVO);
    }

    /**
     * 会员详情 - 会员档案 - 修改入库分类 - 查询结算方式与发票类型
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/record/classify/category/items", method = RequestMethod.GET)
    public Wrapper<MemberClassifyCategoryItemVO> getToClassifyCategoryItems(@RequestHeader HttpHeaders headers) {
        return memberAbilityMaintenanceService.getToClassifyCategoryItems(headers);
    }

    /**
     * 会员详情 - 会员档案 - 修改入库分类信息
     * @param headers HttpHeader信息
     * @param updateVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/record/classify/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberClassification(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberMaintenanceClassificationUpdateVO updateVO) {
        return memberAbilityMaintenanceService.updateMemberClassification(headers, updateVO);
    }

    /**
     * 会员详情 - 会员档案 - 分页查询考察信息
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/inspect/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberRecordInspectPageQueryVO>> pageMemberInspect(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberInspect(headers, pageVO);
    }

    /**
     * 会员详情 - 会员档案 - 分页查询会员整改
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/rectify/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberRecordRectifyVO>> pageMemberRecordRectify(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberRecordRectify(headers, pageVO);
    }

    /**
     * 会员详情- 会员档案 - 分页查询考评信息
     * @param headers HttpHeader信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail/appraisal/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberAppraisalPageQueryVO>> pageMemberAppraisal(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberAppraisal(headers, pageVO);
    }

    /**
     * 会员详情 - 会员等级信息
     * @param headers Http头部信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/level/basic", method = RequestMethod.GET)
    public Wrapper<MemberValidateDetailLevelVO> getMemberLevelDetail(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityMaintenanceService.getMemberLevelDetail(headers, validateVO);
    }

    /**
     * 会员详情 - 会员等级信息 - 分页查询交易分获取记录
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/level/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberDetailLevelHistoryVO>> pageMemberLevelDetailHistory(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberLevelDetailHistory(headers, pageVO);
    }

    /**
     * 会员详情 - 会员权益信息
     * @param headers Http头部信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/right/basic", method = RequestMethod.GET)
    public Wrapper<MemberDetailRightVO> getMemberDetailRight(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityMaintenanceService.getMemberDetailRight(headers, validateVO);
    }

    /**
     * 会员详情 - 会员权益信息 - 分页查询会员权益获取记录
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/right/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberDetailRightHistoryVO>> pageMemberDetailRightHistory(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberDetailRightHistory(headers, pageVO);
    }

    /**
     * 会员详情 - 会员权益信息 - 分页查询会员权益使用记录
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/right/spend/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberDetailRightSpendHistoryVO>> pageMemberDetailRightSpendHistory(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberDetailRightSpendHistory(headers, pageVO);
    }

    /**
     * 会员详情 - 会员信用信息
     * @param headers Http头部信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/basic", method = RequestMethod.GET)
    public Wrapper<MemberDetailCreditVO> getMemberDetailCredit(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityMaintenanceService.getMemberDetailCredit(headers, validateVO);
    }

    /**
     * 会员详情 - 会员信用信息 - 交易评价汇总
     * @param headers Http头部信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/trade/summary", method = RequestMethod.GET)
    public Wrapper<MemberDetailCreditCommentSummaryVO> getMemberDetailCreditTradeCommentSummary(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityMaintenanceService.getMemberDetailCreditTradeCommentSummary(headers, validateVO);
    }

    /**
     * 会员详情 - 会员信用 - 分页查询交易评论历史记录
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/trade/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberDetailCreditTradeHistoryVO>> pageMemberDetailCreditTradeCommentHistory(@RequestHeader HttpHeaders headers, @Valid MemberDetailCreditHistoryPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberDetailCreditTradeCommentHistory(headers, pageVO);
    }

    /**
     * 会员详情 - 会员信用信息 - 售后评价汇总
     * @param headers Http头部信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/aftersale/summary", method = RequestMethod.GET)
    public Wrapper<MemberDetailCreditCommentSummaryVO> getMemberDetailCreditAfterSaleCommentSummary(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityMaintenanceService.getMemberDetailCreditAfterSaleCommentSummary(headers, validateVO);
    }

    /**
     * 会员详情 - 会员信用 - 分页查询售后评论历史记录
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/aftersale/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberDetailCreditAfterSaleHistoryVO>> pageMemberDetailCreditAfterSaleCommentHistory(@RequestHeader HttpHeaders headers, @Valid MemberDetailCreditHistoryPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberDetailCreditAfterSaleCommentHistory(headers, pageVO);
    }

    /**
     * 会员详情 - 会员信用 - 投诉汇总
     * @param headers Http头部信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/complain/summary", method = RequestMethod.GET)
    public Wrapper<MemberDetailCreditComplainSummaryVO> getMemberDetailCreditComplainSummary(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityMaintenanceService.getMemberDetailCreditComplainSummary(headers, validateVO);
    }

    /**
     * 会员详情 - 会员信用 - 分页查询投诉历史记录
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/credit/complain/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberCreditComplaintPageQueryVO>> pageMemberDetailCreditComplainHistory(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberDetailCreditComplainHistory(headers, pageVO);
    }

    /**
     * 会员详情 - 会员变更 - 分页查询会员变更记录
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail/deposit/history/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberDepositDetailHistoryVO>> pageMemberDepositDetailHistory(@RequestHeader HttpHeaders headers, @Valid ValidateIdPageVO pageVO) {
        return memberAbilityMaintenanceService.pageMemberDepositDetailHistory(headers, pageVO);
    }

    /**
     * 根据会员id和角色id，查询会员角色为服务提供者的下级会员列表
     * @param headers HttpHeaders信息
     * @param nameVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/subOrdinate/member/list", method = RequestMethod.GET)
    Wrapper<PageData<MemberManageQueryVO>> subordinateMemberList(@RequestHeader HttpHeaders headers, @Valid MemberNameVO nameVO) {
        return memberAbilityMaintenanceService.subOrdinateMemberList(headers, nameVO);
    }
}
